<template>
  <view class="profile-page">
    <!-- 头部信息区域 -->
    <view class="header">
      <image class="avatar" src="../../static/images/touxiang.png"></image>
      <view class="user-info">
        <view class="user-name">{{userName}}</view>
        <view class="user-phone" v-if="userPhone != null">{{userPhone}}</view>
      </view>
    </view>

    <!-- VIP 开通提示区域 -->
  <!--  <view class="vip-banner">
      <text class="vip-text">VIP</text>
      <text class="vip-desc">开通会员·享更多权益</text>
      <button class="open-vip-btn" @click="openVip">立即开通</button>
    </view> -->
	<view class="function-list function-item" style="display: flex;">
		<view class="w3" @click="toRoute('/pages/basicInfo/basicInfo')" v-if="userType == 'talent'">
			<image class="image" src="../../static/images/jianli.png" mode=""></image>
			<view>我的简历</view>
		</view>
		<view class="w3" v-if="userType == 'talent'">
			<image class="image" src="../../static/images/toudi.png" mode=""></image>
			<view>投递反馈</view>
		</view>
		<view class="w3" @click="toRoute('/pages/liZhi/liZhi')" v-if="userType == 'employee'"> 
			<image class="image" src="../../static/images/toudi.png" mode=""></image>
			<view>离职申请</view>
		</view>
		<view class="w3" @click="toRoute('/pages/yinHangKa/yinHangKa')" v-if="userType == 'employee'">
			<image class="image" src="../../static/images/toudi.png" mode=""></image>
			<view>银行卡</view>
		</view>
		<view class="w3"  v-if="userType == 'talent'">
			<image class="image" src="../../static/images/goutong.png" mode=""></image>
			<view>已沟通过</view>
		</view>
		<view class="w3">
			<image class="image" src="../../static/images/shoucang.png" mode=""></image>
			<view>我的收藏</view>
		</view>
	</view>
    <!-- 功能列表区域 -->
    <view class="function-list">
      <view class="function-item" v-for="(item, index) in functionList" :key="index" @click="changYongGongNengClick(item)">
        <!-- <image class="function-icon" :src="item.icon"></image> -->
		<view class="letTip"></view>
        <text class="function-text">{{item.name}}</text>
        <image class="arrow-icon" src="../../static/images/right.png"></image>
      </view>
    </view>
  </view>
</template>

<script>
	import {
		getInfo
	} from '@/api/login'
	import {getUserType} from '@/utils/auth'
export default {
  data() {
    return {
      // 头像地址（可替换为实际接口返回或本地资源）
      avatarUrl: "/static/avatar.png", 
      userName: "",
      userPhone: "",
	  userType:"",
      functionList: [
        {
          icon: "/static/icon-resume.png",
          name: "我的简历",
          // 对应跳转的页面路径，根据实际路由配置调整
          path: "/pages/resume/resume" 
        },
        {
          icon: "/static/icon-employee.png",
          name: "员工管理",
          path: "/pages/employee/employee"
        },
        // {
        //   icon: "/static/icon-reimburse.png",
        //   name: "报销管理",
        //   path: "/pages/reimburse/reimburse"
        // },
        {
          icon: "/static/icon-system.png",
          name: "系统管理",
          path: "/pages/system/system"
        },
        {
          icon: "/static/icon-collect.png",
          name: "我的收藏",
          path: "/pages/collect/collect"
        }
      ]
    };
  },
  mounted() {
  	this.getUserInfo()
	this.userType = getUserType()
	if(this.userType == 'user'){
		this.functionList = [
        {
          icon: "/static/icon-employee.png",
          name: "员工管理",
          path: "/pages/employee/employee"
        },
        {
          icon: "/static/icon-reimburse.png",
          name: "薪资信息",
          path: "/pages/salaryInfo/salaryInfo"
        },
        {
          icon: "/static/icon-system.png",
          name: "系统管理",
          path: "/pages/system/system"
        },
        {
          icon: "/static/icon-collect.png",
          name: "我的收藏",
          path: "/pages/collect/collect"
        }
      ]
	}else if(this.userType == 'talent'){
		this.functionList = [
        {
          icon: "/static/icon-resume.png",
          name: "我的简历",
          // 对应跳转的页面路径，根据实际路由配置调整
          path: "/pages/resume/resume" 
        },
        // {
        //   icon: "/static/icon-employee.png",
        //   name: "员工管理",
        //   path: "/pages/employee/employee"
        // },
        // {
        //   icon: "/static/icon-reimburse.png",
        //   name: "报销管理",
        //   path: "/pages/reimburse/reimburse"
        // },
        {
          icon: "/static/icon-system.png",
          name: "系统管理",
          path: "/pages/system/system"
        },
        {
          icon: "/static/icon-collect.png",
          name: "我的收藏",
          path: "/pages/collect/collect"
        }
      ]
	}else if(this.userType == 'employee'){
		this.functionList = [
        {
          icon: "/static/icon-resume.png",
          name: "我的简历",
          // 对应跳转的页面路径，根据实际路由配置调整
          path: "/pages/resume/resume" 
        },
        // {
        //   icon: "/static/icon-employee.png",
        //   name: "员工管理",
        //   path: "/pages/employee/employee"
        // },
        // {
        //   icon: "/static/icon-reimburse.png",
        //   name: "报销管理",
        //   path: "/pages/reimburse/reimburse"
        // },
        {
          icon: "/static/icon-system.png",
          name: "系统管理",
          path: "/pages/system/system"
        },
        {
          icon: "/static/icon-collect.png",
          name: "我的收藏",
          path: "/pages/collect/collect"
        }
      ]
	}
  },
  methods: {
	  async getUserInfo(){
	  	let res = await getInfo()
	  	console.log(res,"my----getInfo")
	  	this.userName = res.user.userName;
	  	this.userPhone = res.user.phonenumber
	  },
	  toRoute (e) {
		  uni.navigateTo({
		  	url:e
		  })
	  },
	  changYongGongNengClick(object){
		console.log()
	  	if(object.name === "报销管理"){
	  		uni.navigateTo({
	  			url:"/pages/baoxiao/baoxiao"
	  		})
	  	}else if(object.name === '薪资信息'){
	  		uni.navigateTo({
	  			url:'/pages/salaryInfo/salaryInfo'
	  		})
	  	}else if(object.name === '员工管理'){
	  		uni.navigateTo({
	  			url:'/pages/staffManagement/staffManagement'
	  		})
	  	}else if(object.name === '系统管理'){
			this.$tab.navigateTo('/pages/mine/setting/index')
		}
	  },
    openVip() {
      // 开通会员的逻辑，可跳转至会员购买页面等
      uni.showToast({
        title: "前往开通会员",
        icon: "none"
      });
    },
    goToPage(item) {
      // 跳转页面
      uni.navigateTo({
        url: item.path
      });
    }
  }
};
</script>

<style scoped lang="scss">
.profile-page {
  background-color: #f5f5f5;
  min-height: 100vh;
  padding: 15rpx;
}

.header {
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 20rpx;
  border-radius: 10rpx;
}

.avatar {
  width: 120rpx;
  height: 120rpx;
  border-radius: 60rpx;
}

.user-info {
  margin-left: 20rpx;
}

.user-name {
  font-size: 36rpx;
  font-weight: bold;
}

.user-phone {
  font-size: 28rpx;
  color: #999;
  margin-top: 8rpx;
}

.vip-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, #333, #000);
  color: #fff;
  padding: 20rpx;
  border-radius: 10rpx;
  margin-top: 20rpx;
}

.vip-text {
  font-size: 40rpx;
  font-weight: bold;
  background: -webkit-linear-gradient(left, #ffd700, #ffae00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.vip-desc {
  font-size: 28rpx;
  margin-left: 20rpx;
}

.open-vip-btn {
  background-color: #ff8c00;
  color: #fff;
  font-size: 28rpx;
  padding: 12rpx 30rpx;
  border-radius: 8rpx;
}

.function-list {
  margin-top: 20rpx;
}

.function-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  padding: 20rpx;
  border-radius: 10rpx;
  margin-bottom: 15rpx;
}

.function-icon {
  width: 40rpx;
  height: 40rpx;
}

.function-text {
  font-size: 30rpx;
  margin-left: 15rpx;
  flex: 1;
}

.arrow-icon {
  width: 30rpx;
  height: 30rpx;
}
.letTip {
	width: 9rpx;
	height: 39rpx;
	background-color: #31a889;
}
.w3 {
	width: 33.33%;
	text-align: center;
	.image {
		width: 40px;
		height: 40px;
		object-fit: cover;
	}
	text {
		font-size: 26rpx;
	}
}
</style>